package com.xiaoshou.dao;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.xiaoshou.pojo.Client;

@Repository
public class ClientDao extends BaseDao<Client, String>{

	public Client findClientByHospitalName(String hospitalname) {
		String sql = "from Client where hospitalname = :hospitalname";
		Query query = getSession().createQuery(sql);
		query.setParameter("hospitalname", hospitalname);
		Client c = (Client) query.uniqueResult();
		return c;
	}

	public void saveClient(Client c) {
		String sql = "INSERT INTO CLIENT VALUES(':id',':hospitalname',':chairman',':depart',':address')";
		Query query = getSession().createSQLQuery(sql);
		query.setParameter("id",c.getId());
		query.setParameter("hospital",c.getHospitalname());
		query.setParameter("depart",c.getAddress());
		query.setParameter("address",c.getAddress());
		query.executeUpdate();
	}

}
